import java.io.*;

public class CCNFileSharerClient {
	Handler handler = null;

	private static String commands 	= " ls				: list files.\n"
									+ " refresh			: refresh current dir.\n"
									+ " cd  <dirname>	: change directory to \n"
									+ " get <filename> 	: download file\n"
									+ " quit			: exit ";
	public CCNFileSharerClient(String uri)
	{
		handler = new Handler(uri);
	}
	public CCNFileSharerClient(String uri, String local)
	{	
		handler = new Handler(uri, local);
	}
	public void handle(String command)
	{
		handler.handle(command);
	}
	public static void main(String[] args) {
		CCNFileSharerClient client = new CCNFileSharerClient("ccnx:/test_ftp");
		
		String command = " ";
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(!(command.equalsIgnoreCase("quit") || command.equalsIgnoreCase("q")))
		{
			System.out.println(commands);
			System.out.println(":");
	        try {
	        	command = reader.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        client.handle(command);
		}
		return;
	}	
}
